<template>
	<view class="main" :style="{paddingBottom:(getSafeBottom )+'px'}">
		<navbar title="维权咨询"></navbar>
		
		<view class="content" :style="{paddingTop:(getStateHeight + getNavbar  ) + 'px'}">
			<view class="item">
				<view class="item-label">
					维权流程
				</view>
				<view class="item-image">
					<image @click="previewImage(baseImage + usual.weiquanPicdir)" :src="baseImage + usual.weiquanPicdir" mode="widthFix" v-if="usual.weiquanPicdir"></image>
					<image :src="imgUrl + 'consol.jpg'" mode="widthFix" v-else></image>
				</view>
			</view>
			<view class="item">
				<view class="item-label">
					维权热线电话
				</view>
				<view class="item-label">
					咨询热线：{{usual.weiquanTel}}
				</view>
			</view>
			
			<view class="item-button" @click="add">
				维权/咨询/投诉
			</view>
			
		</view>
		
		<view class="main-bj">
		
		</view>
		
		<!-- 底部登录弹窗 -->
		<van-popup position="bottom" :show="show" :z-index="2300" class="reloadMore" closeable close-icon="close" close-icon-position="top-right" @close="show = false">
			<NotLoginBottom ref="NotLoginBottomRef"></NotLoginBottom>
		</van-popup>
		
	</view>
</template>

<script>
	import {
		mapGetters,
		mapState
	} from 'vuex';
	import Navbar from '@/components/Navbar.vue'
	import NotLoginBottom from '@/components/NotLoginBottom.vue'
	import {getUsual} from "@/core/web-api/common.js"
	export default{
		data(){
			return {
				show:false,
			}
		},
		methods:{
			add(){
				if(this.youkeType){
					this.show=true
				}else{
					uni.navigateTo({
						url:"/pages/web/service/qiuzhiduan/consultAdd"
					})
				}
			},
			previewImage(url) {
				console.log(url)
				// var current = e.target.dataset.src
				let that = this
				uni.previewImage({
					// showmenu:true,
					// current: current,
					urls: [url],
					longPressActions :{
						itemList:['保存图片'],
						success(data) {
							let imgurl = url
							that.saveImage(imgurl)
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					},
					
				})
			},
			saveImage(imgurl){
				// console.log(imgurl)
				uni.downloadFile({
					url:imgurl,
					success(res){
						// console.log(res)
						let url = res.tempFilePath
						uni.saveImageToPhotosAlbum({
							filePath:url,
							success() {
								uni.showToast({
									title:'保存成功',
									icon:"none"
								})
							},
							fail(err) {
								console.log('保存失败',err)
								uni.showToast({
									title:'保存失败',
									icon:"none"
								})
							}
						})
					}
				})
			},
		},
		components:{
			Navbar,NotLoginBottom
		},
		computed: {
			...mapGetters(['getNavbar', 'getStateHeight', 'getSafeBottom']),
			...mapState(['baseImage','usual','imgUrl','youkeType'])
		},
		created() {
		}
	}
</script>

<style scoped lang="less">
	.main {
		width: 100%;
		padding: 0 30upx;
		box-sizing: border-box;
	
		&-bj {
			width: 100%;
			height: 50vh;
			position: fixed;
			left: 0;
			top: 0;
			z-index: -1;
			background: linear-gradient(to bottom, #bdccfb, #f5f5f5);
		}
	
	}
	.content{
		margin-top: 30upx;
		display: flex;
		flex-flow: wrap;
		justify-content: center;
	}
	.item{
		width: 100%;
		background-color: #fff;
		border-radius: 8upx;
		padding:35upx;
		box-sizing: border-box;
		margin-bottom: 40upx;
		&-label{
			font-size: 30upx;
			color: #000000;
			&:nth-child(2){
				margin-top: 40upx;
			}
		}
		&-image{
			margin-top: 30upx;
			width: 100%;
			image{
				width: 100%;
			}
		}
		&-button{
			background: linear-gradient(to bottom, #5472fd, #6ca5fd);
			color: #fff;
			width: 600upx;
			height: 80upx;
			text-align: center;
			line-height: 80upx;
			border-radius: 10upx;
			font-size: 30upx;
			margin-top: 75upx;
		}
	}
	
</style>